package epimarket.beans;

import java.io.Serializable;

@SuppressWarnings("serial")
public class Adresse implements Serializable {
	private int id;
	private String numero_rue;
	private String batiment;
	private int numero_appartement;
	private String voie;
	private String lieu_dit;
	private String ville;
	private int zipcode;
	private String pays;

	public Adresse() {
		this.id = -1;
		this.numero_rue = "";
		this.batiment = "";
		this.numero_appartement = 0;
		this.voie = "";
		this.lieu_dit = "";
		this.ville = "";
		this.zipcode = -1;
		this.pays = "";
	}
	
	public String toString() {
		String str = "";
		str += "Id_adresse_postale = " + this.id + "<br />";
		str += "Id_numero_rue = " + this.numero_rue + "<br />";
		str += "Batiment = " + this.batiment + "<br />";
		str += "Numero appartement = " + this.numero_appartement + "<br />";
		str += "Voie = " + this.voie + "<br />";
		str += "Lieu dit = " + this.lieu_dit + "<br />";
		str += "Ville = " + this.ville + "<br />";
		str += "Zipcode = " + this.zipcode + "<br />";
		str += "Pays = " + this.pays + "<br />";
		return str;
	}
	
	public boolean validate() {
		if (!numero_rue.equals("") && !voie.equals("") && !ville.equals("") &&
			zipcode != -1 && !pays.equals("")) {
			return true;
		} else {
			return false;
		}
	}
	
	/*public static int validate(HttpServletRequest request)
	{
		Adresse addr = new Adresse();
		
		addr.setNumero_rue((request.getParameter("numberroad") != null) ? (String)request.getParameter("numberroad") : "");
		addr.setBatiment((request.getParameter("bat") != null) ? (String)request.getParameter("bat") : "");
		addr.setNumero_appartement((request.getParameter("appart") != null) ? Integer.parseInt(request.getParameter("appart")) : 0);
		addr.setVoie((request.getParameter("road") != null) ? (String)request.getParameter("road") : "");
		addr.setVille((request.getParameter("town") != null) ? (String)request.getParameter("town") : "");
	    addr.setLieu_dit((request.getParameter("subtown") != null) ? (String)request.getParameter("subtown") : "");
		addr.setZipcode((request.getParameter("zipcode") != null) ? Integer.parseInt(request.getParameter("zipcode")) : 0);
		addr.setPays((request.getParameter("country") != null) ? (String)request.getParameter("country") : "");
		return addr.insert(true);
	}*/

	/*
	 * Getter et Setter
	 */
	
	public int getId() {
		return id;
	}

	public void setId(int idd) {
		this.id = idd;
	}

	public String getNumero_rue() {
		return numero_rue;
	}

	public void setNumero_rue(String numero_rue) {
		this.numero_rue = numero_rue;
	}

	public String getBatiment() {
		return batiment;
	}

	public void setBatiment(String batiment) {
		this.batiment = batiment;
	}

	public int getNumero_appartement() {
		return numero_appartement;
	}

	public void setNumero_appartement(int numero_appartement) {
		this.numero_appartement = numero_appartement;
	}

	public String getVoie() {
		return voie;
	}

	public void setVoie(String voie) {
		this.voie = voie;
	}

	public String getLieu_dit() {
		return lieu_dit;
	}

	public void setLieu_dit(String lieu_dit) {
		this.lieu_dit = lieu_dit;
	}

	public String getVille() {
		return ville;
	}

	public void setVille(String ville) {
		this.ville = ville;
	}

	public int getZipcode() {
		return zipcode;
	}

	public void setZipcode(int zipcode) {
		this.zipcode = zipcode;
	}

	public String getPays() {
		return pays;
	}

	public void setPays(String pays) {
		this.pays = pays;
	}
}
